home *** CD-ROM | disk | FTP | other *** search
- Path: news.production.compuserve.com!news
- From: Tom <70215.1323@CompuServe.COM>
- Newsgroups: comp.lang.c
- Subject: Re: Calling a function in variable
- Date: 20 Mar 1996 14:20:39 GMT
- Organization: CompuServe, Inc. (1-800-689-0736)
- Message-ID: <4ip47n$591$1@mhadf.production.compuserve.com>
- References: <4ikjlq$71@Server2.swix.ch>
-
- You can call a function using a pointer variable to a function
- by:
-
- /*prototype */
- void junk_func(void);
-
- void main()
- {
- void (*ptr2func)(); /* define pointer to function */
-
- ptr2func = junk_func; /* assign pointer to function */
-
- (*ptrfunc)(); /* call function */
-
- }
-
-
- void junk_func(void)
- {
- printf ("This function prints a stupid message\n");
- }
-
- Although, this isn't terribly useful, it does show the syntax.
- Tom
-